﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Theme_index_OpenMsg : PowerCreator.LMS.Web.Base.WebBasePage
{
    PowerCreator.LMS.DL.Project.Entity.VOTOUserMsg vo = new PowerCreator.LMS.DL.Project.Entity.VOTOUserMsg();
    PowerCreator.LMS.Web.DL.Project.TOUserMsg obj = new PowerCreator.LMS.Web.DL.Project.TOUserMsg();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    PowerCreator.LMS.DL.Project.Entity.VOTOLearner volearner = new PowerCreator.LMS.DL.Project.Entity.VOTOLearner();
    PowerCreator.LMS.Web.DL.Project.TOLearner objlearer = new PowerCreator.LMS.Web.DL.Project.TOLearner();
    PowerCreator.LMS.DL.Project.Entity.VOTOAdvancedUser voadvanceduser = new PowerCreator.LMS.DL.Project.Entity.VOTOAdvancedUser();
    PowerCreator.LMS.Web.DL.Project.TOAdvancedUser objadvanceduser = new PowerCreator.LMS.Web.DL.Project.TOAdvancedUser();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int msgID = int.Parse(Request.QueryString["MsgID"].ToString());
            //RoundMsg();
            BinderPageData(msgID);
        }
    }

    protected override void InitPage()
    {
        base.InitPage();
    }
    //private void RoundMsg()
    //{
    //    //随机推荐
    //    string search = "";
    //    string orderBy = " NewID() ";
    //    DataTable dt = opNews.Query(search, orderBy, PowerCreator.LMS.Web.Config.WebConfig.PageSize, 1);
    //    rpt_News.DataSource = dt;
    //    rpt_News.DataBind();
    //}
    private void BinderPageData(int msgID)
    {
        vo = obj.Load(msgID);
        if (vo.UserMsg_Id > 0)
        {
            this.Title = vo.Title;
            //if (voNews.NewPictureUrl != null)
            //{
            //    if (voNews.NewPictureUrl.Length > 3)
            //    {
            //        tr_Pic.Visible = true;
            //        lbl_pic.Text = "<img src=\"" + voNews.NewPictureUrl + "\" alt=\"" + voNews.NewTitle + "\" />";
            //    }
            //    else
            //        tr_Pic.Visible = false;
            //}
            //else
            //    tr_Pic.Visible = false;
            lbl_Title.Text = vo.Title;
            lbl_TimePublish.Text = vo.CreateDate.ToString();
            //lbl_countnum.Text = voNews.NewClickNum.ToString();
            lit_NewsContent.Text = vo.Content;
            if (vo.Type == 3)
            {
                volearner = objlearer.Load(vo.Creator);
                lbl_CreatorName.Text = volearner.Name;
                volearner = objlearer.Load(vo.Reciver);
                lbl_ReciverName.Text = volearner.Name;
            }
            else if (vo.Type == 4)
            {
                volearner = objlearer.Load(vo.Creator);
                lbl_CreatorName.Text = volearner.Name;
                voadvanceduser = objadvanceduser.Load(vo.Reciver);
                lbl_ReciverName.Text = voadvanceduser.Name;
            }
            else if (vo.Type == 1)
            {
                voadvanceduser = objadvanceduser.Load(vo.Creator);
                lbl_CreatorName.Text = voadvanceduser.Name;
                volearner = objlearer.Load(vo.Reciver);
                lbl_ReciverName.Text = volearner.Name;
            }

            if (Request.QueryString["type"].ToString() == "2")
            {
                vo.Maek = true;
                obj.Update(vo);
            }
        }
        
    }

}
